home *** CD-ROM | disk | FTP | other *** search
/ Especial Multimedia / Especial Multimedia.iso / Multimed / Prg / DLLGIF.ZIP / GIFDECOD.C < prev    next >
C/C++ Source or Header  |  1993-08-02  |  16KB  |  651 lines

  1. /**************************************************************************
  2.     GIFDECOD.C        Turn a GIF file into a Windows packed DIB
  3.     
  4.     The LZW stuff in here came from CompuServe Graphics Support Forum
  5.     
  6.     I've lost the original, so I cant include the original authors
  7.     comments or credit (SORRY)
  8.     
  9.     See the readme.txt file for the ommissions.
  10.     John Walsh    CompuServe ID 70612,1740
  11.     08 Aug 93        
  12. **************************************************************************/
  13. #include <windows.h>
  14. #include <fcntl.h>
  15. #include <types.h>
  16. #include <stat.h>
  17. #include <stdio.h>
  18. #include <string.h>
  19. #include "gifdll.h"
  20.  
  21. /* a handy little macro to turn 2 BYTES into 1 WORD */
  22. #define BYTE2WORD(a,b)((b<<8)|a)
  23. #define ALIGN_DWORD(X)(((X)+3)/4*4)
  24.  
  25. #define OUT_OF_MEMORY -10
  26. #define BAD_CODE_SIZE -20
  27. #define READ_ERROR -1
  28. #define WRITE_ERROR -2
  29. #define OPEN_ERROR -3
  30. #define CREATE_ERROR -4
  31.  
  32. #define MAX_CODES   4095
  33.  
  34. static int    interlaced;
  35. /* end of interlaced var's */
  36.  
  37. HANDLE FAR PASCAL _export Gif_File_To_DIB(const char*);
  38. static int __near decoder(int);
  39. static int __near Put_Byte_Rout(int);
  40. static int __near out_line(BYTE *, int);
  41. static int __near SetUpInterTable(void);
  42. static int __near init_exp(int);
  43. static int __near get_next_code(void);
  44. __inline static void Bigmemmove(BYTE __huge*,LPSTR,DWORD,DWORD);
  45.  
  46.  
  47. int bad_code_count;
  48. static int curr_size;                     /* The current code size */
  49. static int clear;                         /* Value for a clear code */
  50. static int ending;                        /* Value for a ending code */
  51. static int newcodes;                      /* First available code */
  52. static int top_slot;                      /* Highest code for current size */
  53. static int slot;                          /* Last read code */
  54.  
  55. static int navail_bytes = 0;              /* # bytes left in block */
  56. static int nbits_left = 0;                /* # bits left in current byte */
  57. static BYTE b1;                           /* Current byte */
  58. static BYTE byte_buff[257];               /* Current block */
  59. static BYTE *pbytes;                      /* Pointer to next byte in block */
  60.  
  61. static long code_mask[13] = {
  62.      0,
  63.      0x0001, 0x0003,
  64.      0x0007, 0x000F,
  65.      0x001F, 0x003F,
  66.      0x007F, 0x00FF,
  67.      0x01FF, 0x03FF,
  68.      0x07FF, 0x0FFF
  69.      };
  70.  
  71. static     BYTE stack[MAX_CODES + 1];            /* Stack for storing pixels */
  72. static     BYTE suffix[MAX_CODES + 1];           /* Suffix table */    
  73. static     WORD prefix[MAX_CODES + 1];           /* Prefix linked list */
  74.  
  75.         FILE    *hFile;
  76. static    HANDLE    hBuf,hIntTable=NULL, hHugeBuf;
  77. static  PWORD    pIntTable;
  78. static    WORD     height;
  79. static    DWORD    hIndex, Dwidth;
  80. static    size_t        headsize;
  81. static    short    lc=0;
  82. static     BYTE __huge *pHugeBuf;
  83.  
  84. /**************************************************************************
  85.     FUNCTION: HANDLE FAR PASCAL _export Gif_File_To_DIB(const char* filename)
  86.     
  87.     Give this function a path/filename and it will return a handle
  88.     to a Windows packed DIB (BITMAPINFO w/RGBQUAD + Bits)
  89.     
  90.     It will decode interlaced images too
  91. **************************************************************************/
  92. HANDLE FAR PASCAL _export Gif_File_To_DIB(const char* filename)
  93. {
  94.     LPBITMAPINFO         lpBMI;
  95.     BYTE            bf;
  96.     short            n,i;
  97.     WORD            numents,palsize,bpp,fbpp;
  98.     WORD               ll,a,b;
  99.     HANDLE            hBMI;     
  100.     DWORD            imagesize,Bigimgsize;
  101.  
  102. struct {
  103.         char    signature[3];
  104.         char    version[3];
  105.         WORD     width;
  106.         WORD    height;
  107.         BYTE    bitfield;
  108.         BYTE    backcolor;
  109.         BYTE    pixaspect;
  110.         }lscreen;
  111.         
  112. struct {
  113.         WORD left;
  114.         WORD top;
  115.         WORD width;
  116.         WORD height;
  117.         BYTE bitfield;
  118.         }img_desc;
  119.  
  120.  
  121.     hFile=fopen(filename,"rb");
  122.     if(hFile==NULL)
  123.     {MessageBox(NULL,"file  opening error gifdecod",NULL,MB_ICONHAND|MB_SYSTEMMODAL);
  124.         return NULL;}
  125.  
  126.     rewind(hFile);
  127.  
  128.     for(i=0;i<3;i++)
  129.         lscreen.signature[i]=(char)fgetc(hFile);
  130.     for(i=0;i<3;i++)
  131.         lscreen.version[i]=(char)fgetc(hFile);
  132.  
  133.     a=(WORD)fgetc(hFile);
  134.     b=(WORD)fgetc(hFile);
  135.     ll=lscreen.width=BYTE2WORD(a,b);
  136.     a=(WORD)fgetc(hFile);
  137.     b=(WORD)fgetc(hFile);
  138.     height=lscreen.height=BYTE2WORD(a,b);
  139.     lscreen.bitfield=(BYTE)fgetc(hFile);
  140.     lscreen.backcolor=(BYTE)fgetc(hFile);
  141.     lscreen.pixaspect=(BYTE)fgetc(hFile);
  142.  
  143. if(lscreen.bitfield && 128)
  144. {
  145.    bf=(BYTE)(lscreen.bitfield<<5);
  146.    bpp=(WORD)((bf>>5)+1);
  147.    switch(bpp)
  148.     {
  149.      case 1:
  150.     fbpp=8;
  151.     break;
  152.     case 2:
  153.     case 3:
  154.     case 4:
  155.     fbpp=8;
  156.     break;
  157.     case 5:
  158.     case 6:
  159.     case 7:
  160.     case 8:
  161.     fbpp=8;
  162.     break;
  163.     }
  164.        numents=(2<< fbpp-1);
  165.        palsize=numents*(WORD)sizeof(RGBQUAD);
  166.     headsize=(size_t)sizeof(BITMAPINFOHEADER)+(size_t)palsize;
  167.     
  168.     if((hBMI=GlobalAlloc(GHND,headsize))==NULL)
  169.     {MessageBox(NULL,"hBMI alloc error gif",
  170.         NULL,MB_ICONASTERISK|MB_SYSTEMMODAL);
  171.         return NULL;
  172.     }
  173.     if((lpBMI=(LPBITMAPINFO)GlobalLock(hBMI))==NULL)
  174.     {MessageBox(NULL,"Class m_hBMI Lock error gif",
  175.             NULL,MB_ICONASTERISK|MB_SYSTEMMODAL);
  176.         return NULL;
  177.     }
  178.     switch(bpp)
  179.     {
  180.  
  181.     case 1:
  182.     {
  183.         lpBMI->bmiColors[0].rgbRed=(BYTE)fgetc(hFile);
  184.         lpBMI->bmiColors[0].rgbGreen=(BYTE)fgetc(hFile);
  185.         lpBMI->bmiColors[0].rgbBlue=(BYTE)fgetc(hFile);
  186.         lpBMI->bmiColors[0].rgbReserved=0;
  187.         lpBMI->bmiColors[1].rgbRed=(BYTE)fgetc(hFile);
  188.         lpBMI->bmiColors[1].rgbGreen=(BYTE)fgetc(hFile);
  189.         lpBMI->bmiColors[1].rgbBlue=(BYTE)fgetc(hFile);
  190.         lpBMI->bmiColors[1].rgbReserved=0;
  191.     break;
  192.     }
  193.  
  194.     case 2:
  195.     {
  196.         for(n=0;n<4;n++)
  197.         {
  198.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  199.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  200.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  201.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  202.         }
  203.     break;
  204.     }
  205.  
  206.     case 3:
  207.     {
  208.         for(n=0;n<8;n++)
  209.         {
  210.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  211.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  212.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  213.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  214.         }
  215.     break;
  216.     }
  217.  
  218.     case 4:
  219.     {
  220.         for(n=0;n<16;n++)
  221.         {
  222.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  223.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  224.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  225.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  226.         }
  227.     break;
  228.     }
  229.  
  230.     case 5:
  231.     {
  232.         for(n=0;n<32;n++)
  233.         {
  234.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  235.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  236.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  237.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  238.         }
  239.     break;
  240.     }
  241.  
  242.     case 6:
  243.     {
  244.         for(n=0;n<64;n++)
  245.         {
  246.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  247.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  248.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  249.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  250.         }
  251.     break;
  252.     }
  253.  
  254.     case 7:
  255.     {
  256.         for(n=0;n<128;n++)
  257.         {
  258.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  259.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  260.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  261.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  262.         }
  263.     break;
  264.     }
  265.  
  266.     case 8:
  267.     {
  268.         for(n=0;n<256;n++)
  269.         {
  270.         lpBMI->bmiColors[n].rgbRed=(BYTE)fgetc(hFile);
  271.         lpBMI->bmiColors[n].rgbGreen=(BYTE)fgetc(hFile);
  272.         lpBMI->bmiColors[n].rgbBlue=(BYTE)fgetc(hFile);
  273.         lpBMI->bmiColors[n].rgbReserved=(BYTE)0;
  274.         }
  275.     break;
  276.     }
  277. }
  278.  
  279. }
  280.     n=fgetc(hFile);        // should be 0x2C image descriptor label
  281.     if(n!=0x2C)            // but if it is'nt
  282.        while(n!=0x2C)   // throw stuff away till it does
  283.           n=fgetc(hFile);// yep- no support for extensions
  284.             
  285.     a=(WORD)fgetc(hFile);
  286.     b=(WORD)fgetc(hFile);
  287.     img_desc.left=BYTE2WORD(a,b);
  288.     a=(WORD)fgetc(hFile);
  289.     b=(WORD)fgetc(hFile);
  290.     img_desc.top=BYTE2WORD(a,b);
  291.     a=(WORD)fgetc(hFile);
  292.     b=(WORD)fgetc(hFile);
  293.     img_desc.width=BYTE2WORD(a,b);
  294.     a=(WORD)fgetc(hFile);
  295.     b=(WORD)fgetc(hFile);
  296.     img_desc.height=BYTE2WORD(a,b);
  297.     img_desc.bitfield=(BYTE)fgetc(hFile);
  298.  
  299.      ll=img_desc.width-img_desc.left;
  300.      height=img_desc.height-img_desc.top;
  301.  
  302.     interlaced=img_desc.bitfield&64;
  303.     Dwidth=(ALIGN_DWORD(ll));
  304.     imagesize=(DWORD)height*(DWORD)Dwidth;
  305. // end of file reading stuff????
  306.  
  307.     lpBMI->bmiHeader.biSize         = (sizeof(BITMAPINFOHEADER));
  308.     lpBMI->bmiHeader.biWidth        = (WORD)ll;
  309.     lpBMI->bmiHeader.biHeight        = height;
  310.     lpBMI->bmiHeader.biPlanes        =1;
  311.     lpBMI->bmiHeader.biBitCount        =fbpp;
  312.     lpBMI->bmiHeader.biCompression    =BI_RGB;
  313.     lpBMI->bmiHeader.biSizeImage    =(DWORD)height*(DWORD)Dwidth;
  314.     lpBMI->bmiHeader.biXPelsPerMeter=0L;
  315.     lpBMI->bmiHeader.biYPelsPerMeter=0L;
  316.     lpBMI->bmiHeader.biClrUsed        =0L;
  317.     lpBMI->bmiHeader.biClrImportant    =(DWORD)(2<<bpp-1);
  318.  
  319. // LETS RETURN HERE IF ITS AN IMAGE QUERY
  320. // PROCESS THE IMAGE IF ITS NOT A QUERY
  321.  
  322. /* interlaced setup routine*/
  323.     if(interlaced)
  324.        SetUpInterTable();
  325. /* end of interlace setup*/
  326.  
  327.     Bigimgsize=imagesize+(DWORD)headsize;
  328.  
  329.     GlobalCompact(Bigimgsize);
  330.  
  331.     if((hHugeBuf=GlobalAlloc(GHND,Bigimgsize*sizeof(BYTE)))==NULL)
  332.         {MessageBox(NULL,"memory alloc error HUGE",NULL,MB_ICONHAND|MB_SYSTEMMODAL);
  333.         return NULL;}
  334.     if((pHugeBuf=(BYTE __huge*)GlobalLock(hHugeBuf))==NULL)
  335.         {MessageBox(NULL,"memory lock error HUGE",NULL,MB_ICONHAND|MB_SYSTEMMODAL);
  336.         return NULL;}
  337.  
  338. /*******************end interlaced buffer ********************************/
  339.  
  340.     _fmemcpy(pHugeBuf,lpBMI,(size_t)headsize);
  341.     hIndex=Bigimgsize-Dwidth;
  342.  
  343.  
  344. n=decoder(ll);
  345.  
  346.        GlobalUnlock(hHugeBuf);
  347.  
  348.     fclose(hFile);
  349.     
  350.     if(hIntTable!=NULL)
  351.     {
  352.         LocalUnlock(hIntTable);
  353.         LocalFree(hIntTable);
  354.     }    
  355.  
  356. return hHugeBuf;
  357. }
  358.  
  359. /****************************************************************************
  360.     Outline is easier now that we got huge
  361. *****************************************************************************/
  362.  
  363. int __near out_line(BYTE pixels[], int linelen)
  364. {
  365.  
  366.     if(!interlaced)
  367.     {
  368.         Bigmemmove(pHugeBuf,(LPSTR)pixels,(DWORD)linelen,(DWORD)hIndex);
  369.         hIndex-=Dwidth;
  370.     }
  371.     else
  372.     {
  373.         Bigmemmove(pHugeBuf,(LPSTR)pixels,(DWORD)linelen,
  374.                     ((DWORD)headsize)+(DWORD)pIntTable[lc]*(DWORD)Dwidth);
  375.         lc+=1;
  376.     }
  377.     return 0;
  378. }
  379.  
  380. static int __near init_exp(int size)
  381. {
  382.    curr_size = size + 1;
  383.    top_slot = 1 << curr_size;
  384.    clear = 1 << size;
  385.    ending = clear + 1;
  386.    slot = newcodes = ending + 1;
  387.    navail_bytes = nbits_left = 0;
  388.    return(0);
  389. }
  390.  
  391. static int __near get_next_code(void)
  392. {
  393.    int i, x;
  394.    DWORD ret;
  395.  
  396.        if (nbits_left == 0)
  397.        {
  398.           if (navail_bytes <= 0)
  399.           {
  400.              pbytes = byte_buff;
  401.              if ((navail_bytes = getc(hFile)) < 0)
  402.                 return(navail_bytes);
  403.              else if (navail_bytes)
  404.              {
  405.                 for (i = 0; i < navail_bytes; ++i)
  406.                 {
  407.                        if ((x = getc(hFile)) < 0)
  408.                           return(x);
  409.                        byte_buff[i] = (BYTE)x;
  410.                 }
  411.               }
  412.           }
  413.           b1 = *pbytes++;
  414.           nbits_left = 8;
  415.           --navail_bytes;
  416.     }
  417.  
  418.        ret = b1 >> (8 - nbits_left);
  419.        while (curr_size > nbits_left)
  420.     {
  421.           if (navail_bytes <= 0)
  422.         {
  423.              pbytes = byte_buff;
  424.              if ((navail_bytes = getc(hFile)) < 0)
  425.                 return(navail_bytes);
  426.              else if (navail_bytes)
  427.             {
  428.                 for (i = 0; i < navail_bytes; ++i)
  429.                    {
  430.                        if ((x = getc(hFile)) < 0)
  431.                           return(x);
  432.                        byte_buff[i] = (BYTE)x;
  433.                    }
  434.             }
  435.          }
  436.           b1 = *pbytes++;
  437.           ret |= b1 << nbits_left;
  438.           nbits_left += 8;
  439.           --navail_bytes;
  440.     }
  441.        nbits_left -= curr_size;
  442.        ret &= code_mask[curr_size];
  443.        return((int)(ret));
  444. }
  445.  
  446. int __near decoder(int linewidth)
  447. {
  448.        register BYTE *sp, *bufptr;
  449.        BYTE *buf;
  450.        register int code, fc, oc, bufcnt;
  451.        int c, size, ret;
  452.     HANDLE hBuf;
  453.  
  454.     if ((size = getc(hFile)) < 0)
  455.           return(size);
  456.        if (size < 2 || 9 < size)
  457.           return(BAD_CODE_SIZE);
  458.        init_exp(size);
  459.        oc = fc = 0;
  460.        if((hBuf=LocalAlloc(LMEM_MOVEABLE|LMEM_ZEROINIT,linewidth+1))==NULL)
  461.            return OUT_OF_MEMORY;
  462.     if((buf=(BYTE *)LocalLock(hBuf))==NULL)
  463.         return OUT_OF_MEMORY;
  464.        sp = stack;
  465.        bufptr = buf;
  466.        bufcnt = linewidth;
  467.        while ((c = get_next_code()) != ending)
  468.     {
  469.           if (c < 0)
  470.         {
  471.               LocalUnlock(hBuf);
  472.               LocalFree(hBuf);
  473.              return(0);
  474.         }
  475.           if (c == clear)
  476.         {
  477.              curr_size = size + 1;
  478.              slot = newcodes;
  479.              top_slot = 1 << curr_size;
  480.              while ((c = get_next_code()) == clear);
  481.              if (c == ending)
  482.                 break;
  483.              if (c >= slot)
  484.                 c = 0;
  485.  
  486.              oc = fc = c;
  487.              *bufptr++ = (BYTE)c;
  488.              if (--bufcnt == 0)
  489.             {
  490.                 if ((ret = out_line(buf, linewidth)) < 0)
  491.                    {
  492.                        LocalUnlock(hBuf);
  493.                        LocalFree(hBuf);
  494.                        return(ret);
  495.                    }
  496.                 bufptr = buf;
  497.                 bufcnt = linewidth;
  498.             }
  499.           }
  500.           else
  501.         {
  502.              code = c;
  503.  
  504.              if (code >= slot)
  505.             {
  506.                 if (code > slot)
  507.                        ++bad_code_count;
  508.                 code = oc;
  509.                 *sp++ = (BYTE)fc;
  510.             }
  511.              while (code >= newcodes)
  512.             {
  513.                 *sp++ = suffix[code];
  514.                 code = prefix[code];
  515.             }
  516.              *sp++ = (BYTE)code;
  517.              if (slot < top_slot)
  518.             {
  519.                 suffix[slot] = fc = code;
  520.                 prefix[slot++] = oc;
  521.                 oc = c;
  522.             }
  523.              if (slot >= top_slot)
  524.                 if (curr_size < 12)
  525.                    {
  526.                        top_slot <<= 1;
  527.                        ++curr_size;
  528.                    }
  529.              while (sp > stack)
  530.             {
  531.                 *bufptr++ = *(--sp);
  532.                 if (--bufcnt == 0)
  533.                    {
  534.                        if ((ret = out_line(buf, linewidth)) < 0)
  535.                       {
  536.                          LocalUnlock(hBuf);
  537.                          LocalFree(hBuf);
  538.                           return(ret);
  539.                       }
  540.                        bufptr = buf;
  541.                        bufcnt = linewidth;
  542.                    }
  543.             }
  544.         }
  545.     } 
  546.                           
  547.        ret = 0;
  548.        if (bufcnt != linewidth)
  549.           ret = out_line(buf, (linewidth - bufcnt));
  550.           
  551.     LocalUnlock(hBuf);
  552.     LocalFree(hBuf);
  553.        return(ret);
  554. }
  555.  
  556. /*************************************************************************/
  557. // Here we set up a tabel of Image Line Numbers so we know where to put
  558. // the lines of an interlaced gif.
  559. //
  560. /*************************************************************************/
  561.  
  562. int __near SetUpInterTable(void)
  563. {
  564.     WORD     cc;  
  565.     WORD    ci1=0,ci2=1,ci3=1,ci4=1;
  566.     WORD    p1,p2,p3,p4;
  567.     int        set1=1,set2=1,set3=1,set4=1;
  568.     
  569.  
  570.         p1=(int)height/(WORD)8;
  571.         p2=p1;
  572.         p3=(int)height/(WORD)4;
  573.         p4=(int)height/(WORD)2;
  574.  
  575.     LocalCompact(height);
  576.  
  577.     if((hIntTable=LocalAlloc(LMEM_MOVEABLE|LMEM_ZEROINIT,
  578.                             (height+1)*sizeof(WORD)))==NULL)
  579.     {
  580.         MessageBox(NULL,"local alloc error -interlaced gif table",
  581.                     NULL,MB_ICONHAND|MB_SYSTEMMODAL);
  582.         return NULL;
  583.     }
  584.     if((pIntTable=(PWORD)LocalLock(hIntTable))==NULL)
  585.     {
  586.         MessageBox(NULL,"local lock error -interlaced gif table",
  587.                     NULL,MB_ICONHAND|MB_SYSTEMMODAL);
  588.         return NULL;
  589.     }
  590.     
  591.     height--;
  592.     lc=0;
  593.     for(cc=0;cc<height;cc++)
  594.     {
  595.         if(ci1<p1)
  596.         {
  597.             pIntTable[cc]=height-(WORD)(ci1*8);
  598.             ci1+=1;
  599.         }
  600.         else if(ci2<p2)
  601.         {
  602.             if(set2)
  603.             {
  604.                 pIntTable[cc]=height-(WORD)4;
  605.                 set2=0;
  606.             }
  607.             else
  608.             {
  609.                 pIntTable[cc]=height-(WORD)(4+(ci2*8));
  610.                 ci2+=1;
  611.             }
  612.          }
  613.          else if(ci3<p3)
  614.          {
  615.               if(set3)
  616.               {
  617.                   pIntTable[cc]=height-(WORD)2;
  618.                   set3=0;
  619.               }
  620.               else
  621.               {
  622.                   pIntTable[cc]=height-(WORD)(2+(ci3*4));
  623.                   ci3+=1;
  624.               }
  625.           }
  626.           else if(ci4<p4)
  627.           {
  628.               if(set4)
  629.               {
  630.                   pIntTable[cc]=height-(WORD)1;
  631.                   set4=0;
  632.               }
  633.               else
  634.               {
  635.                   pIntTable[cc]=height-(WORD)(1+(ci4*2));
  636.                   ci4+=1;
  637.               }
  638.          }
  639.     }
  640.     height++;
  641. }
  642.  
  643. __inline void Bigmemmove(BYTE __huge*Dest,LPSTR Src,DWORD Num, DWORD spos)
  644. {
  645.    DWORD    x;  
  646.     
  647.     for(x=0;x<Num;x++)
  648.     Dest[spos+x]=(BYTE)Src[(short)x];
  649.        return;
  650. }
  651.